<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="month">
    <button id="btn">获取当月的天数</button>
    <script>
        // 用switch语句
        var monthBox = document.getElementById('month')
        var btnBox = document.getElementById('btn')
        // 点击按钮时，执行函数（获取文本框的值，做判断）
        btnBox.onclick = function () {
            var monthValue = Number(monthBox.value) // '1' => 1
            switch(monthValue){
                case 1:
                    console.log('31天')
                    break
                case 2: 
                    console.log('28天')
                    break
                case 3: 
                    console.log('31天')
                    break
                case 4: 
                    console.log('30天')
                    break
                default:
                    console.log('略')
                    // break
            }
        }
    </script>
    <!-- 2 29 -->
</body>
</html>